//
//  HXMaterialerTCell.m
//  ZCooking
//
//  Created by 韩旭 on 16/9/14.
//  Copyright © 2016年 HX_. All rights reserved.
//

#import "HXMaterialerTCell.h"
#import "HXMaterialerCCell.h"
#import "HX_Macro.h"
#import "HXMarterialerMoreCell.h"
#import "HXMaterLikeModel.h"

@implementation HXMaterialerTCell
- (void)setPhoto:(NSMutableArray *)photo {
    _photo = photo;
    [_moreCollecitonView reloadData];
}
- (void)setHeaderArr:(NSMutableArray *)headerArr {
    _headerArr = headerArr;
    [_headerCollectionVIew reloadData];
}

- (void)setUp {
    self.headerCollectionVIew.delegate = self;
    self.headerCollectionVIew.dataSource = self;
    self.headerCollectionVIew.backgroundColor = [UIColor whiteColor];
    _headerCollectionVIew.showsHorizontalScrollIndicator = NO;
    self.headerFlower.scrollDirection = 1;
    [_headerCollectionVIew registerNib:[UINib nibWithNibName:@"HXMaterialerCCell" bundle:[NSBundle mainBundle]] forCellWithReuseIdentifier:@"HXMaterialerCCell"];
    self.moreCollecitonView.delegate = self;
    self.moreCollecitonView.dataSource = self;
    _moreCollecitonView.showsHorizontalScrollIndicator = NO;
    self.moreFlower.scrollDirection = 1;
    self.moreCollecitonView.backgroundColor = [UIColor whiteColor];
    [_moreCollecitonView registerNib:[UINib nibWithNibName:@"HXMarterialerMoreCell" bundle:[NSBundle mainBundle]] forCellWithReuseIdentifier:@"HXMarterialerMoreCell"];
}
- (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView {
    return 1;
}
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
    if (collectionView == _headerCollectionVIew) {
        return self.headerArr.count;
    } else {
        return self.photo.count;
    }
}
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
    if (collectionView == _headerCollectionVIew) {
        HXMaterialerCCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"HXMaterialerCCell" forIndexPath:indexPath];
        HXMaterLikeModel *like = self.headerArr[indexPath.row];
        [cell.headerImg sd_setImageWithURL:[NSURL URLWithString:like.head_img] placeholderImage:[UIImage imageNamed:@"userHeadImage"]];
        cell.backgroundColor = [UIColor whiteColor];
        return cell;
    } else {
        HXMarterialerMoreCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"HXMarterialerMoreCell" forIndexPath:indexPath];
        [cell.photoWork sd_setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@", [self.photo[indexPath.row] image]]]];
        return cell;
    }
}
- (CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout minimumLineSpacingForSectionAtIndex:(NSInteger)section {
    if (collectionView == _headerCollectionVIew) {
        return 10;
    } else {
        return 0;
    }
}
- (CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout minimumInteritemSpacingForSectionAtIndex:(NSInteger)section {
    if (collectionView == _headerCollectionVIew) {
        return 10;
    } else {
        return 0;
    }
}
- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath {
    if (collectionView == _headerCollectionVIew) {
        return CGSizeMake(40, 40);
    } else {
        return CGSizeMake(self.contentView.HX_width / 3.5, 80);
    }
}
- (void)awakeFromNib {
    [self setUp];
    self.detailLabel.font = [UIFont systemFontOfSize:14];
    self.detailLabel.numberOfLines = 0;
    self.personImg.layer.masksToBounds = YES;
    self.personImg.contentMode = UIViewContentModeScaleAspectFill;
    self.personImg.layer.cornerRadius = 20;
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];
    
    // Configure the view for the selected state
}

@end
